----------------------------------------------------------------
-- Global Variables
----------------------------------------------------------------

CreateAuctionWindow =
{
    DEBUG_ON = false,
    
    -- Strings
    titleBarText = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_TITLE ),
    
    --itemHeader = L"Auction Item",
    durationHeader = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_DURATION_LABEL ),
    bidPriceHeader = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_BID_PRICE_LABEL ),
    buyOutPriceHeader = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_BUY_OUT_PRICE_LABEL ),
    
    depositLabel = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_DEPOSIT_LABEL ),
    vendorPriceLabel = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_VENDOR_PRICE_LABEL ),
    moneyAvailableLabel = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_MONEY_LABEL ),
    
    createButtonText = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_CREATE_BUTTON ),
    clearButtonText = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_CLEAR_BUTTON ),
    
    -- Restriction Type Strings
    RESTRICTION_TYPE_ANY_TEXT       = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_RESTRICTION_TYPE_ANY_TEXT ), 
    RESTRICTION_TYPE_ALLIANCE_TEXT  = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_RESTRICTION_TYPE_ALLIANCE_TEXT ), 
    RESTRICTION_TYPE_GUILD_TEXT     = GetStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_RESTRICTION_TYPE_GUILD_TEXT ), 
  
    -- Duration Strings
	DURATION_SHORT_TEXT		= GetFormatStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_DURATION_CHOICE_TEXT, { GameData.Auction.CREATE_AUCTION_DURATION_SHORT } ),
	DURATION_MEDIUM_TEXT	= GetFormatStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_DURATION_CHOICE_TEXT, { GameData.Auction.CREATE_AUCTION_DURATION_MEDIUM } ),
	DURATION_LONG_TEXT		= GetFormatStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_DURATION_CHOICE_TEXT, { GameData.Auction.CREATE_AUCTION_DURATION_LONG } ),
	DURATION_VERY_LONG_TEXT	= GetFormatStringFromTable( "AuctionHouseStrings",  StringTables.AuctionHouse.CREATE_AUCTION_DURATION_CHOICE_TEXT, { GameData.Auction.CREATE_AUCTION_DURATION_VERY_LONG } ),

 
    -- Constants
    DEFAULT_BID_PRICE_MULTIPLIER = 1.5,
    DEFAULT_BUY_OUT_PRICE_MULTIPLIER = 2.0,
    
    MINIMUM_DEPOSIT_PRICE = 1,
    
    
	-- TODO: Eventually the server should let the client know when a player/guild
	--		 has unlocked Guild Auctions. Currently the client doesn't 
	--		have a way of telling this, so instead of hardcoding a guild rank
	--		that will change we simply show Guild Only when you're in a guild,
	--		and show Guild and Alliance once you're in an alliance. If your guild
	--		doesn't have the proper permissions, then the server will let you
	--		know why the auction did not succeed.
    REQUIRED_GUILD_RANK_TO_CREATE_GUILD_ONLY_AUCTIONS = 1,
    REQUIRED_GUILD_RANK_TO_CREATE_GUILD_AND_ALLIANCE_AUCTIONS = 1,
    
    -- Variables
    itemInventorySlot = { slot = 0, backpack = 0 },
    itemJustPickedUp = false,
    
    -- because not all RestrictionChoice values are displayed, we need to keep this as a mapping
    --   between the Combo Box indices and the RestrictionChoice data to be used
    RestrictionChoiceDisplayed = {},
}

CreateAuctionWindow.Duration =
{ 
    {   text = CreateAuctionWindow.DURATION_SHORT_TEXT,  
		value = GameData.Auction.DURATION_INDEX_SHORT,    
		depositPercent = GameData.Auction.DEPOSIT_MULTIPLIER_SHORT,  },  
		
     {   text = CreateAuctionWindow.DURATION_MEDIUM_TEXT,  
		value = GameData.Auction.DURATION_INDEX_MEDIUM,    
		depositPercent = GameData.Auction.DEPOSIT_MULTIPLIER_MEDIUM,  },  
		
    {   text = CreateAuctionWindow.DURATION_LONG_TEXT,  
		value = GameData.Auction.DURATION_INDEX_LONG,    
		depositPercent = GameData.Auction.DEPOSIT_MULTIPLIER_LONG,  },  
		
    {   text = CreateAuctionWindow.DURATION_VERY_LONG_TEXT,  
		value = GameData.Auction.DURATION_INDEX_VERY_LONG,    
		depositPercent = GameData.Auction.DEPOSIT_MULTIPLIER_VERY_LONG,  },  

}


CreateAuctionWindow.DefaultDurationIndex = 2

--  Guild Only or Alliance Only searches

CreateAuctionWindow.RESTRICTION_NONE = 1
CreateAuctionWindow.RESTRICTION_ALLIANCE = 2
CreateAuctionWindow.RESTRICTION_GUILD = 3

CreateAuctionWindow.RestrictionChoice =
{ 
    [CreateAuctionWindow.RESTRICTION_NONE] =		{   text = CreateAuctionWindow.RESTRICTION_TYPE_ANY_TEXT,        value = GameData.Auction.RESTRICTION_NONE,    },  
    [CreateAuctionWindow.RESTRICTION_ALLIANCE] =	{   text = CreateAuctionWindow.RESTRICTION_TYPE_ALLIANCE_TEXT,   value = GameData.Auction.RESTRICTION_GUILD_ALLIANCE_ONLY,    },  
    [CreateAuctionWindow.RESTRICTION_GUILD] =		{   text = CreateAuctionWindow.RESTRICTION_TYPE_GUILD_TEXT,      value = GameData.Auction.RESTRICTION_GUILD_ONLY,    },  
}

CreateAuctionWindow.DefaultRestrictionChoiceIndex = CreateAuctionWindow.RESTRICTION_NONE

-- END TODO: LOCALIZE

----------------------------------------------------------------
-- Local Variables
----------------------------------------------------------------

--local windowName = "CreateAuctionWindow"
local windowName = "AuctionHouseWindowCreateAuction"


----------------------------------------------------------------
-- Local Functions
----------------------------------------------------------------

local function SendDebug( text )
    
	if CreateAuctionWindow.DEBUG_ON then
        DEBUG( text )
    end
end


----------------------------------------------------------------
-- CreateAuctionWindow Functions
----------------------------------------------------------------

function CreateAuctionWindow.Initialize()
SendDebug(L"CreateAuctionWindow.Initialize")

    WindowRegisterEventHandler (windowName, SystemData.Events.PLAYER_MONEY_UPDATED, "CreateAuctionWindow.UpdateMoneyAvailable" )
	
    -- Set all static data    
    LabelSetText( windowName.."TitleBarText", CreateAuctionWindow.titleBarText )
    --LabelSetText( windowName.."ItemHeader", CreateAuctionWindow.itemHeader )
    LabelSetText( windowName.."DurationComboBoxHeader", CreateAuctionWindow.durationHeader )
    LabelSetText( windowName.."BidPriceHeader", CreateAuctionWindow.bidPriceHeader )
    LabelSetText( windowName.."BuyOutPriceHeader", CreateAuctionWindow.buyOutPriceHeader )
    
    LabelSetText( windowName.."DepositHeader", CreateAuctionWindow.depositLabel )
    LabelSetText( windowName.."VendorPriceHeader", CreateAuctionWindow.vendorPriceLabel )
    LabelSetText( windowName.."MoneyAvailableHeader", CreateAuctionWindow.moneyAvailableLabel )
    
    ButtonSetText( windowName.."CreateButton", CreateAuctionWindow.createButtonText )
    ButtonSetText( windowName.."ClearButton", CreateAuctionWindow.clearButtonText )

    -- choices in the duration drop down box
    for index, duration in ipairs( CreateAuctionWindow.Duration ) do
        ComboBoxAddMenuItem( windowName.."DurationComboBox", duration.text )
    end

end

function CreateAuctionWindow.Shutdown()

end

function CreateAuctionWindow.OnShown()
SendDebug(L"CreateAuctionWindow.OnShown")

	CreateAuctionWindow.FullClear()
end

function CreateAuctionWindow.OnHidden()
SendDebug(L"CreateAuctionWindow.OnHidden")
    CreateAuctionWindow.FullClear()
end


function CreateAuctionWindow.Clear()
SendDebug(L"CreateAuctionWindow.Clear")

    DynamicImageSetTexture( windowName.."ItemImageIcon", "", 0, 0 )
    LabelSetText( windowName.."ItemName", L"" )
    ButtonSetText( windowName.."ItemImage", L"" )

    --MoneyFrame.FormatMoney (windowName.."MoneyAvailablePrice", Player.GetMoney(), MoneyFrame.HIDE_EMPTY_WINDOWS)
    MoneyFrame.FormatMoney( windowName.."BidPrice", 0, MoneyFrame.SHOW_EMPTY_WINDOWS )
    MoneyFrame.FormatMoney( windowName.."BuyOutPrice", 0, MoneyFrame.SHOW_EMPTY_WINDOWS )
    
    MoneyFrame.FormatMoney( windowName.."DepositPrice", 0, MoneyFrame.HIDE_EMPTY_WINDOWS )
    MoneyFrame.FormatMoney( windowName.."VendorPrice", 0, MoneyFrame.HIDE_EMPTY_WINDOWS )
    
    ButtonSetDisabledFlag( windowName.."CreateButton", true )
	
	if ( CreateAuctionWindow.itemInventorySlot.slot > 0 )
    then
	    EA_BackpackUtilsMediator.ReleaseLockForSlot(CreateAuctionWindow.itemInventorySlot.slot, CreateAuctionWindow.itemInventorySlot.backpack, windowName )
	    CreateAuctionWindow.itemInventorySlot = { slot = 0, backpack = 0 }
	end
end


function CreateAuctionWindow.FullClear()

	CreateAuctionWindow.Clear()
    ComboBoxSetSelectedMenuItem( windowName.."DurationComboBox", CreateAuctionWindow.DefaultDurationIndex)

    CreateAuctionWindow.UpdateRestrictionTypes()

end


function CreateAuctionWindow.Show()
SendDebug(L"CreateAuctionWindow.Show")

    WindowSetShowing( windowName, true )
    CreateAuctionWindow.UpdateMoneyAvailable()
end

function CreateAuctionWindow.Hide()
SendDebug(L"CreateAuctionWindow.Hide")
    WindowSetShowing( windowName, false )
end

function CreateAuctionWindow.ToggleShowing()
SendDebug(L"CreateAuctionWindow.ToggleShowing")

    if ( CreateAuctionWindow.IsShowing() == true ) then
        CreateAuctionWindow.Hide()
    else
        CreateAuctionWindow.Show()
    end
end

function CreateAuctionWindow.IsShowing()
SendDebug(L"CreateAuctionWindow.IsShowing")
    return WindowGetShowing( windowName )
end

function CreateAuctionWindow.UpdateMoneyAvailable()
SendDebug(L"CreateAuctionWindow.UpdateMoneyAvailable")

    if CreateAuctionWindow.IsShowing() then
SendDebug(L"   Player.GetMoney() = "..Player.GetMoney())
        MoneyFrame.FormatMoney (windowName.."MoneyAvailable", Player.GetMoney(), MoneyFrame.HIDE_EMPTY_WINDOWS)
    end
end

function CreateAuctionWindow.Create()  
SendDebug(L"CreateAuctionWindow.Create")
--[[
    local typeIndex = ComboBoxGetSelectedMenuItem("CreateAuctionWindowCombo")
    local typeString = CreateAuctionWindow.Duration[typeIndex]
    local slashCommand = L"/AuctionHouse "

    SystemData.UserInput.ChatText = slashCommand..typeString..L" "..CreateAuctionWindowText.Text
    BroadcastEvent( SystemData.Events.SEND_CHAT_TEXT )

    CreateAuctionWindow.Hide()
--]]
    -- sanity checks
    if ( ButtonGetDisabledFlag( windowName.."CreateButton") == true ) or
       ( itemInventorySlot == 0 ) then
        
        Sound.Play( Sound.ACTION_FAILED )
        return
    end
        
    local startingBidPrice = MoneyFrame.ConvertCurrencyToBrass( windowName.."BidPrice" )
    local buyOutPrice = MoneyFrame.ConvertCurrencyToBrass( windowName.."BuyOutPrice" )
    
    local durationChoice = ComboBoxGetSelectedMenuItem( windowName.."DurationComboBox" )
    local auctionLength = CreateAuctionWindow.Duration[durationChoice].value
    
    local restrictionChoice = ComboBoxGetSelectedMenuItem( windowName.."RestrictionComboBox" )
	local restrictionType = CreateAuctionWindow.RestrictionChoiceDisplayed[restrictionChoice].value
    
    CreateAuction( CreateAuctionWindow.itemInventorySlot.slot, CreateAuctionWindow.itemInventorySlot.backpack, startingBidPrice, buyOutPrice, auctionLength, restrictionType ) 

    Sound.Play( Sound.AUCTION_HOUSE_CREATE_AUCTION )

    CreateAuctionWindow.Clear() 
end


function CreateAuctionWindow.ItemSlotMouseOver()
SendDebug(L"CreateAuctionWindow.ItemSlotMouseOver")
    local iconWindowName = SystemData.ActiveWindow.name
    
    if( CreateAuctionWindow.itemInventorySlot.slot > 0 )
    then 
        local itemData = EA_BackpackUtilsMediator.GetItemsFromBackpack( CreateAuctionWindow.itemInventorySlot.backpack )[CreateAuctionWindow.itemInventorySlot.slot]
        if itemData and itemData.id and itemData.id > 0 then
            Tooltips.CreateItemTooltip (itemData, iconWindowName, Tooltips.ANCHOR_WINDOW_RIGHT)
        end
    end

end 


function CreateAuctionWindow.PickupItemIfPossible()
SendDebug(L"CreateAuctionWindow.PickupItemIfPossible")
    CreateAuctionWindow.itemJustPickedUp = false
    
    if CreateAuctionWindow.itemInventorySlot.slot > 0 then
    
        if not Cursor.IconOnCursor() then
            local backpackType = EA_BackpackUtilsMediator.GetCurrentBackpackType()
            local itemData = EA_BackpackUtilsMediator.GetItemsFromBackpack( CreateAuctionWindow.itemInventorySlot.backpack )[CreateAuctionWindow.itemInventorySlot.slot]
            if ( itemData ~= nil ) and 
               ( EA_BackpackUtilsMediator.ReleaseLockForSlot(CreateAuctionWindow.itemInventorySlot.slot, CreateAuctionWindow.itemInventorySlot.backpack, windowName) ) then

                local cursor = EA_BackpackUtilsMediator.GetCursorForBackpack( CreateAuctionWindow.itemInventorySlot.backpack )
                Cursor.PickUp( cursor, CreateAuctionWindow.itemInventorySlot.slot, itemData.uniqueID, itemData.iconNum, true )
                CreateAuctionWindow.Clear()
                
                CreateAuctionWindow.itemJustPickedUp = true
            end
        end
    end
SendDebug(L"   returning "..StringToWString( tostring(CreateAuctionWindow.itemJustPickedUp) ) )
    return CreateAuctionWindow.itemJustPickedUp
end


-- TODO: see what other situations than soulbound items that 
--   we con't want to auction, e.g. low rarity or player crafted items
function CreateAuctionWindow.ItemIsAuctionable( itemData )

    --return (itemData.boundToPlayer == false)
    return true
end


-- TODO: in the future maybe this could cache previous prices
--   at minimum, remember the items added during this session,
--   but saving to a local file would be great
--
-- TODO: also see if maybe we can factor in the bidPrice into the deposit
--   to solve the problem where we have way too low of a vendor price on 
--   some items.
function CreateAuctionWindow.UpdateItemPrices( itemData )

    -- TODO: need to multiply by stack count
    
    local basePrice = itemData.sellPrice * itemData.stackCount
    local durationChoice = ComboBoxGetSelectedMenuItem( windowName.."DurationComboBox" )
    local depositPercent = CreateAuctionWindow.Duration[durationChoice].depositPercent
    local depositPrice = math.floor( basePrice * depositPercent )    
    
    if depositPrice < CreateAuctionWindow.MINIMUM_DEPOSIT_PRICE then
		depositPrice = CreateAuctionWindow.MINIMUM_DEPOSIT_PRICE
    end
    
    local currentBidPrice = MoneyFrame.ConvertCurrencyToBrass( windowName.."BidPrice" )
    if currentBidPrice == 0 then 
        local bidPrice = math.floor( basePrice * CreateAuctionWindow.DEFAULT_BID_PRICE_MULTIPLIER )
        local buyOutPrice = math.floor( basePrice * CreateAuctionWindow.DEFAULT_BUY_OUT_PRICE_MULTIPLIER )

        MoneyFrame.FormatMoney( windowName.."BidPrice", bidPrice, MoneyFrame.SHOW_EMPTY_WINDOWS )
        MoneyFrame.FormatMoney( windowName.."BuyOutPrice", buyOutPrice, MoneyFrame.SHOW_EMPTY_WINDOWS )
    end
    
    MoneyFrame.FormatMoney( windowName.."DepositPrice", depositPrice, MoneyFrame.HIDE_EMPTY_WINDOWS )
    MoneyFrame.FormatMoney( windowName.."VendorPrice", basePrice, MoneyFrame.HIDE_EMPTY_WINDOWS )

end


function CreateAuctionWindow.OnRestrictionTypeChanged()
SendDebug(L"CreateAuctionWindow.OnRestrictionTypeChanged")

end




function CreateAuctionWindow.UpdateRestrictionTypes()
SendDebug(L"CreateAuctionWindow.UpdateRestrictionTypes")
	
	ComboBoxClearMenuItems( windowName.."RestrictionComboBox" )
	CreateAuctionWindow.RestrictionChoiceDisplayed = {}
	
	local restriction = CreateAuctionWindow.RestrictionChoice[CreateAuctionWindow.RESTRICTION_NONE]
	ComboBoxAddMenuItem( windowName.."RestrictionComboBox", restriction.text )
	table.insert( CreateAuctionWindow.RestrictionChoiceDisplayed, restriction )
    
	if CreateAuctionWindow.PlayerCanCreateAllianceAuctions() then
		restriction = CreateAuctionWindow.RestrictionChoice[CreateAuctionWindow.RESTRICTION_ALLIANCE]
		ComboBoxAddMenuItem( windowName.."RestrictionComboBox", restriction.text )
		table.insert( CreateAuctionWindow.RestrictionChoiceDisplayed, restriction )
	end
	
	if CreateAuctionWindow.PlayerCanCreateGuildAuctions() then
		restriction = CreateAuctionWindow.RestrictionChoice[CreateAuctionWindow.RESTRICTION_GUILD]
		ComboBoxAddMenuItem( windowName.."RestrictionComboBox", restriction.text )
		table.insert( CreateAuctionWindow.RestrictionChoiceDisplayed, restriction )
	end
	
    ComboBoxSetSelectedMenuItem( windowName.."RestrictionComboBox", CreateAuctionWindow.DefaultRestrictionChoiceIndex)
end



function CreateAuctionWindow.PlayerCanCreateGuildAuctions()

	local inGuild = GuildWindow and GuildWindow.IsPlayerInAGuild()
	local playerMeetsRequirement = ( inGuild and GameData.Guild.m_GuildRank and
									GameData.Guild.m_GuildRank >= CreateAuctionWindow.REQUIRED_GUILD_RANK_TO_CREATE_GUILD_ONLY_AUCTIONS
								   )
	return playerMeetsRequirement
end

-- if you're high enough guild rank to be in alliance we let you search on Guild and Alliance auctions
function CreateAuctionWindow.PlayerCanCreateAllianceAuctions()

	local meetsGuildReq = CreateAuctionWindow.PlayerCanCreateGuildAuctions()
	local meetsAllianceReq = ( meetsGuildReq and (GameData.Guild.Alliance.Id ~= 0) and
							   GameData.Guild.m_GuildRank >= CreateAuctionWindow.REQUIRED_GUILD_RANK_TO_CREATE_GUILD_AND_ALLIANCE_AUCTIONS
							 )
	return meetsAllianceReq
end

    
    

function CreateAuctionWindow.OnDurationChanged()
SendDebug(L"CreateAuctionWindow.OnDurationChanged")

    if CreateAuctionWindow.itemInventorySlot.slot > 0
    then
        local itemData = EA_BackpackUtilsMediator.GetItemsFromBackpack( CreateAuctionWindow.itemInventorySlot.backpack )[CreateAuctionWindow.itemInventorySlot.slot]
        CreateAuctionWindow.UpdateItemPrices( itemData )
    end
end

function CreateAuctionWindow.UpdateForItem( itemData )
SendDebug(L"CreateAuctionWindow.UpdateForItem")

    local texture, x, y = GetIconData( itemData.iconNum )
    DynamicImageSetTexture( windowName.."ItemImageIcon", texture, x, y )
    LabelSetText( windowName.."ItemName", itemData.name )
    -- Stack Count            
    if( itemData.stackCount > 1 ) then
        ButtonSetText( windowName.."ItemImage", L""..itemData.stackCount )
    else
        ButtonSetText( windowName.."ItemImage", L"" )
    end
    
    CreateAuctionWindow.UpdateItemPrices( itemData )
    
    ButtonSetDisabledFlag( windowName.."CreateButton", false )
end

function CreateAuctionWindow.DropItemIfPossible()
SendDebug(L"CreateAuctionWindow.DropItemIfPossible")

    --if Cursor.IconOnCursor() and CreateAuctionWindow.dropPending == false then
    if Cursor.IconOnCursor() and not CreateAuctionWindow.itemJustPickedUp then

        local isTrial, _ = GetAccountData()
        
        if( isTrial )
        then
            EA_TrialAlertWindow.Show(SystemData.TrialAlert.ALERT_AUCTION)
            
            return
        end
    
        local backpackType = EA_BackpackUtilsMediator.GetCurrentBackpackType()
        local currentCursor = EA_BackpackUtilsMediator.GetCursorForBackpack( backpackType )
        if Cursor.Data and Cursor.Data.Source == currentCursor
        then
            local inventorySlot = Cursor.Data.SourceSlot
            local itemData = EA_BackpackUtilsMediator.GetItemsFromBackpack( backpackType )[inventorySlot]
            
            -- acquiring lock on inventory slot number
            if ( itemData ) and 
               ( CreateAuctionWindow.ItemIsAuctionable( itemData ) ) and
               ( EA_BackpackUtilsMediator.RequestLockForSlot( inventorySlot, backpackType, windowName ) ) then
                
                Cursor.Clear ()
                
                -- Check to see if there was an item already in slot that we need to pick up
                if CreateAuctionWindow.itemInventorySlot.slot > 0 then
                    CreateAuctionWindow.PickupItemIfPossible()
                end
                
SendDebug(L"   added")
                CreateAuctionWindow.UpdateForItem( itemData )
                
                CreateAuctionWindow.itemInventorySlot = { slot = inventorySlot, backpack = backpackType }
            end
        end
        
        
    end 
    
    CreateAuctionWindow.itemJustPickedUp = false   
end

-- OnLButtonDown Handler
function CreateAuctionWindow.ItemSlotLButtonDown()

    CreateAuctionWindow.PickupItemIfPossible()
end

-- OnLButtonUp Handler
function CreateAuctionWindow.ItemSlotLButtonUp()
SendDebug(L"CreateAuctionWindow.ItemSlotLButtonUp")

    CreateAuctionWindow.DropItemIfPossible()
end

-- OnRButtonUp Handler
function CreateAuctionWindow.ItemSlotRButtonUp ()

    CreateAuctionWindow.Clear()
    
    --if CreateAuctionWindow.PickupItemIfPossible() then
    --	Cursor.Clear ()
    --end

end


function CreateAuctionWindow.PutInventoryItemUpForAuction( slot, itemData )

	-- commenting out since this wasn't working. I think the PickUp call doesn't put the data in the Cursor.Data field until
	--		a frame later or something
	
	--Cursor.PickUp( Cursor.SOURCE_INVENTORY, slot, itemData.uniqueID, itemData.iconNum, true )
	--CreateAuctionWindow.DropItemIfPossible()
	--Cursor.Clear ()
end


